package jbrowser.session;

import java.net.URI;
import jbrowser.api.ClassLoadingException;

public class ClassPathSession implements Session {

    public static String HOST = "jbrowser";

    @Override
    public String getHost() {
        return HOST;
    }

    public ClassLoader getClassLoader() {
        return getClass().getClassLoader();
    }

    @Override
    public Class loadClass(URI uri) throws ClassLoadingException {
        try {
            return Class.forName(uri.getSchemeSpecificPart(), true, getClassLoader());
        } catch (Exception ex) {
            throw new ClassLoadingException(ex);
        }
    }
}
